﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Acando.Dynamics.CRM.Silverlight.Library.Helper;
using Acando.Dynamics.CRM.Silverlight.Library.CrmSdk;

namespace Acando.Dynamics.CRM.Silverlight.Library.Dialogs
{
    public partial class LoginDialog : UserControl
    {
        private Panel Parent { get; set; }

        public event EventHandler DialogClosed;

        public LoginDialog()
        {
            this.Parent = ApplicationContext.Current.GetParentForDialogs();
            InitializeComponent();
        }

        public void ShowDialog()
        {
            //CrmAuthHeader a = ApplicationContext.Current.AuthHeader;
            
            //if (a != null)
            //{
            //    txtDomain.Text = a.Domain;
            //    txtOrg.Text = a.Organization;
            //    txtUser.Text = a.Username;
            //    txtPwd.Password = a.Password;
            //}

            //this.Parent.Children.Add(this);


        }

        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            //this.btnOk.IsEnabled = false;
            //ApplicationContext.Current.AuthHeader = new CrmAuthHeader() { Username = txtUser.Text, Domain = txtDomain.Text, Organization = txtOrg.Text, Password = txtPwd.Password };
            //this.Visibility = Visibility.Collapsed;
            this.DialogClosed(this, new EventArgs());
        }

       
    }
}
